      1  import javax.swing.JButton;

      2  import javax.swing.JFrame;

      3  import javax.swing.JLabel;

      4  import javax.swing.JPanel;

      5

      6  /**

      7     A frame that is filled with two components.

      8  */

      9  public class FilledFrame extends JFrame

     10  {

     11     private JButton button;

     12     private JLabel label;

     13

     14     private static final int FRAME_WIDTH = 300;

     15     private static final int FRAME_HEIGHT = 100;

     16

     17     public FilledFrame()

     18     {

     19        createComponents();

     20        setSize(FRAME_WIDTH, FRAME_HEIGHT);

     21     }

     22

     23     private void createComponents()

     24     {

     25        button = new JButton("Click me!");

     26        label = new JLabel("Hello, World!");

     27

     28        JPanel panel = new JPanel();

     29        panel.add(button);

     30        panel.add(label);

     31        add(panel);

     32     }

     33  }